/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mbeans;

import common.ProdQta;
import ejb.OrderManagerLocal;
import java.util.*;
import javax.ejb.EJB;

/**
 *
 * @author sflesca
 */
public class CarrelloBean {
    @EJB
    private OrderManagerLocal orderManager;
    
    List<ProdQta> items = new LinkedList<ProdQta>();
    Long idcliente = new Long(1);

    /**
     * Creates a new instance of Carrello
     */
    public CarrelloBean() {
        
    }
    
    public String addToChart(Long prodotto, Integer qta){
        items.add(new ProdQta(prodotto,qta));
        return "Carrello";
    }
    
    public List<ProdQta> getProdCarrello(){
        return items;
    }
    
    public String order(){
        orderManager.issueOrder(idcliente, items);
        items.clear();
        return "Carrello";
    }
}
